package Tests;


import static org.junit.Assert.assertTrue;
import model.locations.Level;
import model.things.Ogre;
import model.things.You;

import org.junit.Before;
import org.junit.Test;

import exceptions.InvalidDirectionException;
import exceptions.LockedDoorException;
import exceptions.NoDoorException;
import exceptions.OutOfBoundsException;


public class LevelTest {

	Level level;
	You player;
	
	
	@Before
	public void setup(){
	
	player= new You("TestPlayer",1,2);
	try {
		level=	new Level(3,'s',2,2,1,1,player);
		level.addBoundary(1, 1, true, false);//wall
		level.addBoundary(1, 2, true, true);//door
		level.addThing(new Ogre("OGRE",0,2));
		level.update();//update things surrounding player
		
	} catch (OutOfBoundsException e) {
		e.printStackTrace();
	} catch (InvalidDirectionException e) {
		e.printStackTrace();
	}
	
	}
	
	@Test
	public void getDescriptionArea(){
		
		String status="";
		try {
			status=level.getDescriptionArea(1,2);
		} catch (OutOfBoundsException e) {
			e.printStackTrace();
		}
		System.out.println(status);
	}
	
	@Test
	public void testStatusWall(){
		String status="";
		try {
			status=level.getStatusBoundary(1, 1, true);
		} catch (OutOfBoundsException e) {
			e.printStackTrace();
		}
	assertTrue(status=="BLOCKED");
	}
	
	@Test
	public void testStatusDoor(){
		String status="";
		try {
			status=level.getStatusBoundary(1, 2, true);
		} catch (OutOfBoundsException e) {
			e.printStackTrace();
		}
		assertTrue(status=="CLOSED");
	}
	
	@Test
	public void openDoor(){
		String status="";
		boolean openSuccess=false;
			try {
				openSuccess=level.openAndClose(true);  //open door
				status=level.getStatusBoundary(1, 2, true);
				assertTrue(status=="OPEN");
				
			} catch (LockedDoorException e) {
				e.printStackTrace();
			} catch (NoDoorException e) {
				e.printStackTrace();
			} catch (OutOfBoundsException e) {
				e.printStackTrace();
			}
			
	}
	
	@Test
	public void testDoor(){
		String status="";
		try {
			status=level.getStatusBoundary(1, 2, true);
		} catch (OutOfBoundsException e) {
			e.printStackTrace();
		}
		assertTrue(status=="CLOSED");
	}
	

}
